<template>
	<!-- 订单通知 -->
	<view>
		<view class="" v-if="list.length >0">
			<view class="newlist" v-for="(item,index) in list" :key="index" @click="handlenavigate(item)">
				<view class="headPortrait flex-cb">
					<view class="flex img">
						<text>{{item.order.type==1?'物流订单':item.order.type==3?'配送订单':item.order.type==4?'点餐订单':'自提订单'}}通知</text>
						<text class="cuIcon-title" v-if="item.mch_is_read!=1"></text>
					</view>
					<view class="time">{{item.created_at}}</view>
				</view>
				<view class="newContent">{{item.content}}</view>
				<view class="solid"></view>
				<view class="flex-cb last">
					<text>查看详情</text>
					<text class="cuIcon-right"></text>
				</view>
			</view>
		</view>
		<nodata v-else />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[]
			};
		},
		onLoad() {
			this.$api.order_tz({
				limit:100
			}).then(res=>{
				console.log(res);
				this.list = res.list
			})
		},
		methods:{
			// 订单类型 1物流配送 2自提订单 3商家配送 4点餐订单 5服务订单
			handlenavigate(item){
				let that = this
				getApp().globalData.isgoto = ''
				if(item.order.type == 1){
					uni.navigateTo({
						url:'/pageA/order/WL_details?id='+item.order.id,
						success() {
							that.setNews(item.id)
						}
					})
				}
				if(item.order.type == 2||item.order.type == 5){
					uni.navigateTo({
						url:'/pageA/order/ZT_details?id='+item.order.id,
						success() {
							that.setNews(item.id)
						}
					})
				}
				if(item.order.type == 3){
					uni.navigateTo({
						url:'/pageA/order/PS_details?id='+item.order.id,
						success() {
							that.setNews(item.id)
						}
					})
				}
				if(item.order.type == 4){//点餐订单没有详情页
					uni.navigateTo({
						url:'./order?type='+item.order.type,
						success() {
							that.setNews(item.id)
						}
					})
				}
				
					
			},
			setNews(id){//设置已读
				this.$api.merchants_order_messages_read({
					order_message_id:id
				}).then(res=>{
					console.log(res);
				})
			}
		}
	}
</script>

<style lang="scss">
.newlist{
	width: 710rpx;
	// height: 320rpx;
	background: #FFFFFF;
	border-radius: 10rpx;
	margin:20rpx auto;
	// margin-bottom: 20rpx;
	// padding: 0 0 0 51rpx;
	.headPortrait{
		padding:20rpx 20rpx 0 20rpx;
		.img{
			font-size: 34rpx;
			font-weight: bold;
		}
		.cuIcon-title{
			font-size: 40rpx;
			color: #FF2E2E;
			margin-right: 43rpx;
		}
	}
	.newContent{
		font-size: 28rpx;
		padding: 0 20rpx;
		font-weight: 400;
		color: #919AA5;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		line-height: 39rpx;
		margin-top: 30rpx;
		margin-bottom: 35rpx;
	}
	.last{
		height: 80rpx;
		padding: 0 20rpx;
	}
	.time{
		color: #A7A6A9;
		font-size: 26rpx;
	}
}
</style>
